package com.hunliji.monitor.web.facade.impl;

import com.hunliji.common.response.PageData;
import com.hunliji.monitor.service.api.UserInfoService;
import com.hunliji.monitor.service.api.model.bo.UserInfoBO;
import com.hunliji.monitor.service.api.model.param.QueryUserParam;
import com.hunliji.monitor.share.utils.PageDataUtil;
import com.hunliji.monitor.web.facade.UserFacade;
import com.hunliji.monitor.web.model.vo.UserBasicInfoVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户
 * @author wuchen
 */
@Service
public class UserFacadeImpl implements UserFacade {
    @Resource
    private UserInfoService userInfoService;
    @Override
    public List<UserBasicInfoVO> queryUserBasicList(QueryUserParam queryUserParam) {
        PageData<UserInfoBO> pageData = userInfoService.queryPage(queryUserParam);
        if(pageData.getTotalCount() == 0){
            return new ArrayList<>();
        }
        List<UserInfoBO> userInfoBOList = pageData.getList();
        List<UserBasicInfoVO> userBasicInfoVOList = new ArrayList<>();
        for (UserInfoBO userInfoBO:userInfoBOList){
            UserBasicInfoVO userBasicInfoVO = new UserBasicInfoVO();
            userBasicInfoVO.setId(userInfoBO.getId());
            userBasicInfoVO.setName(userInfoBO.getName());
            userBasicInfoVOList.add(userBasicInfoVO);
        }
        return userBasicInfoVOList;
    }
}
